package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller//当前类为控制器
@ResponseBody//返回的是数据而非页面
public class TestController {

    @RequestMapping("/hi")//url路由注册
    public String sayHi(String name){
        //name==null||name.equals("")
        if(!StringUtils.hasLength(name)){
            name="张三";
        }
        return "你好: "+name;
    }
}
